Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sets #3846

Closed
wants to merge 45 commits into from
Closed

Add Sets #3846

wants to merge 45 commits into from

Conversation

NoahCardoso
Copy link
Collaborator

Closes #2655. WIP, I currently have created sets in expr.

@NoahCardoso NoahCardoso changed the title Set Add Sets Jul 10, 2024
Copy link
Collaborator

@balacij balacij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shaping up nicely! I think you'll also want to add the new operators to the Expr typeclasses that define the smart constructors of the various Exprs:

Comment on lines 42 to 47
-- | Helpful for filtering for Physical constraints. True if constraint is 'Physical'.
isPhysC (Range Physical _) = True
isPhysC _ = False
isPhysRange (Range Physical _) = True
isPhysRange _ = False

isPhysElem (Elem Physical _) = True
isPhysElem _ = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the differentiation needed between Range and Elem for this? Why are the isX functions needed at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used for formatting constraints. I don't think a distinction between the two would need to be made here

-- | Formats Physical Constraints into a 'Sentence'.
fmtPhys :: (Constrained c, Quantity c) => c -> Sentence
fmtPhys c = foldConstraints c $ filter isPhysC (c ^. constraints)
-- | Formats Software Constraints into a 'Sentence'.
fmtSfwr :: (Constrained c, Quantity c) => c -> Sentence
fmtSfwr c = foldConstraints c $ filter isSfwrC (c ^. constraints)

-- | Returns a pair of a chunk and its physical constraints.
physLookup :: HasUID q => ConstraintCEMap -> q -> (q, [ConstraintCE])
physLookup m q = constraintLookup q m (filter isPhysC)
-- | Returns a pair of a chunk and its software constraints.
sfwrLookup :: HasUID q => ConstraintCEMap -> q -> (q, [ConstraintCE])
sfwrLookup m q = constraintLookup q m (filter isSfwrC)

@@ -70,6 +70,18 @@ data UFuncVV = NegV
data UFuncVN = Norm | Dim
deriving Eq

-- | Set + Set -> Set
data SSet = SUnion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the pattern below, I think this would be SSSBinOp? Union is also associative, so you can build it similar to the other associative operations.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree ___BinOp would probably be better. For Union I was thinking of doing
data AssocConcatOper = SUnion
deriving Eq

Comment on lines 78 to 83
data ESSSet = SAdd | SRemove
deriving Eq

-- | Element + Set -> Bool
data ESBSet = SContains
deriving Eq
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with above on naming.

@@ -109,7 +120,7 @@ data Expr where
Case :: Completeness -> [(Expr, Relation)] -> Expr
-- | Represents a matrix of expressions.
Matrix :: [[Expr]] -> Expr

Set :: Expr -> Expr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor should take in a Set (or list if we don't have an Ord instance for Expr) of Exprs.


infer cxt (Set e) =
case infer cxt e of
Left sp -> if S.isBasicNumSpace sp then Left sp else Right (show sp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need to restrict ourselves to only numeric sets. For example, power sets and string sets are probably things we want. However, we can probably just admit anything in the set, so as long as the elements are of the same type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this was left in by accident.

@balacij
Copy link
Collaborator

balacij commented Jul 10, 2024

Have you also started on the conversion of the Exprs into GOOL?

@NoahCardoso
Copy link
Collaborator Author

Yes I have started some of the conversions of expr in GOOL. I wanted to ensure I was on the right path before getting too deep into GOOL.

@balacij
Copy link
Collaborator

balacij commented Jul 23, 2024

It would be good to merge in changes from main sooner rather than later. I think @B-rando1 is making some large changes, so he can best advise with how things changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add back OneOf Value constraints
2 participants